{% extends 'base_loggedin.html' %}
{% block title %}
{{ block.super }} | Dashboard
{% endblock %}
{% block block_content %}
    <div class="top">
        <p class="left">Dashboard</p>
    </div>

    <div class="center">

        <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td colspan="6" align="right">
                <a class="btn" href="/manage_conduits/" title="Edit/Remove Conduits">Manage Conduits</a>
                &nbsp;&nbsp;&nbsp;
                <a class="btn" href="/new_feed/" title="Subscribe to a new feed">New feed</a>
                &nbsp;&nbsp;&nbsp;
                <a class="btn" href="/new_cloudserver/" title="Create a new cloud server">New server</a>
            </td>
        </tr>
        </table>

       <h3>Feeds</h3>
        {% for sub in feeds %}
            <table width="100%" cellpadding="0" cellspacing="0">
            <tr id="item_{{ forloop.counter }}" class="{% cycle 'color' 'sin_color' %}">
                <td width="11%" align="center">
                    <!--a href="/activate" title="">
                        <img src="/media/images/ico_tilde.png" alt="" />
                    </a-->
                    &nbsp;
                    <a title="Delete this feed"
                        href="javascript:if (confirm('Are you sure you want to delete {{ sub.name }} feed?')) { window.location = '/delete_feed/{{ sub.id }}'; }">
                        <img src="/media/images/ico_cruz.png" alt="" />
                    </a>
                    &nbsp;
                    <a href="{{ sub.url }}" title="Go to this feed" target="_blank">
                        <img src="/media/images/ico_rss.png" alt="{{ sub.url }}" />
                    </a>
                </td>
                <td >
                    {{ sub.name }}
                    &nbsp;
                    <a href="/edit_feed/{{ sub.id }}" title="Edit this feed">Edit</a>
                </td>
                <td width="18%" align="center">
                    {{ sub.last_update|date|default:"Not updated yet" }}
                </td>
                <td width="25%" align="center">
                    {% for conduit in sub.conduits.all %}
                    {{conduit.name}} {% if not forloop.last %} <br/> {% endif %}
                    {% endfor %}
                </td>
                <!--td width="12%" align="center">
                    <a href="/edit_feed/{{sub.id}}">Edit Feed</a>
                </td-->
                <!--td width="8%" align="center">
                    <a class="mas" href="javascript:mas(<?=$i?>);" title="">More +</a>
                </td-->
            </tr>
            </table>
            <!--div id="mas_ds" class="mas" style="display:none">
                Lorem ipsum...
            </div-->
        {% empty %}
        <p>You are not subscribed to any feed yet. Go to <a href="/new_feed/">New feed</a> to add a new one.</p>
        {% endfor %}

       <h3>Cloud Servers</h3>
        {% for cloudserver in cloudservers %}
            <table width="100%" cellpadding="0" cellspacing="0">
            <tr id="server_{{ forloop.counter }}" class="{% cycle 'color' 'sin_color' %}">
                <td width="21%" align="center">
                    <a title="Delete this server"
                        href="javascript:if (confirm('Are you sure you want to delete {{ cloudserver.name }} server?')) { window.location = '/delete_cloudserver/{{ cloudserver.id }}'; }">
                        <img src="/media/images/ico_cruz.png" alt="" />
                    </a>
                    &nbsp;
                    <a href="{{ cloudserver.url }}" title="Go to this server's feed" target="_blank">
                        <img src="/media/images/ico_rss.png" alt="{{ cloudserver.url }}" />
                    </a>
                  <form method="post" action="{% url ping_cloudserver cloudserver.id %}" style="display:
                    inline">
		      <input type="hidden" name="url" value="{{ cloudserver.url }}">
                      <button name="submit" type="submit" title="Notify server about feed update" target="_blank">
                            <img src="/media/images/gtk-refresh.png" alt="Ping" />
                      </button>
                  </form>
                    <a href="{% url help_cloudserver cloudserver.id %}" title="Show instructions for this server">
                        <img src="/media/images/help-faq.png" alt="Help" />
                    </a>
                    <a href="{% url feed_cloudserver cloudserver.id %}" title="Go to cloud server's feed" target="_blank">
                        <img src="/media/images/stock_weather-cloudy.png" alt="RSSCloud" />
                    </a>
                </td>
                <td >
                    {{ cloudserver.name }}
                    &nbsp;
                    <a href="/edit_cloudserver/{{ cloudserver.id }}" title="Edit this server">Edit</a>
                </td>
                <td width="18%" align="center">
                    {{ cloudserver.last_update|date|default:"Not updated yet" }}
                </td>
                  <td align="center" title="Number of subscribers for this cloud server">
                  {{ cloudserver.serversubscriber_set.count }}
              </td>
            </tr>
            </table>
        {% empty %}
        <p>You don't have any cloud server yet. Go to <a href="/new_cloudserver/">New cloud server</a> to add a new one.</p>
        {% endfor %}
    </div>

{% endblock %}
